﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HtmlAgilityPack;

namespace PriceAlertService
{
    public class GetStockInfo
    {
        public static float GetMatchPrice(string stockSymbol)
        {
            try
            {
                var doc = new HtmlWeb().Load("http://www.bsc.com.vn/Overview.aspx?Symbol="+stockSymbol);
                var matchPriceNode = doc.DocumentNode.SelectNodes("//span[@quote='L' and @symbol='" + stockSymbol + "']").FirstOrDefault();
                if (matchPriceNode != null)
                {
                    return float.Parse(matchPriceNode.InnerHtml);
                }
            }
            catch (Exception e)
            {
                throw;
            }
            return -1;
        }
    }
}